{extend name="wap@style/base"/}
{block name="resources"}
<link rel="stylesheet" href="ADDON_NC_WAP_ARTICLE_CSS/reward.css"/>
{/block}
{block name="head"}
<header class="hui-header">
    <div id="hui-back" onclick="window.history.back();"></div>
    <h1>赞赏</h1>
</header>
{/block}
{block name="main"}
{php}
$article_id = input('article_id', 0);
{/php}
<div class="reward-block">
    <div class="reward-article">
        <div class="reward-article-head">
            {notempty name="$site_info.icon"}
            <img src="{:img($site_info.icon)}">
            {else /}
            <img src="WEB_ADDON_IMG/default-logo.png">
            {/notempty}
        </div>
        <div class="reward-article-name">{$site_info.site_name}</div>
    </div>


    <div class="reward-values hui-flex" style="flex-wrap:wrap;">
        <div class="reward-values-item reward-values-item-selected"><i>1</i>元</div>
        <div class="reward-values-item"><i>5</i>元</div>
        <div class="reward-values-item"><i>10</i>元</div>
        <div class="reward-values-item"><i>20</i>元</div>
        <div class="reward-values-item"><i>99</i>元</div>
        <div class="reward-values-item"><i>199</i>元</div>
    </div>

    {php}
    $pay_info = api("Member.Member.getPayTacticsConfig",[]);
    {/php}
    <div class="reward-pay-type" >
        <ul class="reward-pay-type-ul">

            <li class="reward-pay-type-item">
                <span>在线支付</span>
                <!-- 单全框 -->
                <div class="reward-pay-type-item-radio">
                    <input type="radio" value="1" name="pay_type"  checked/>
                </div>
            </li>
            {if !empty($pay_info["data"]["value"])}
            <li class="reward-pay-type-item">
                <span>{$pay_info["data"]["value_info"]["name"]}支付</span>
                <!-- 单全框 -->
                <div class="reward-pay-type-item-radio">
                    <input type="radio" value="2" name="pay_type" />
                </div>
            </li>
            {/if}
        </ul>
    </div>
    <div class="reward-bottom">
        <button class="reward-submit">确定</button>
    </div>
</div>

<script>
//金额选择
$(".reward-values-item").click(function(){
    $(".reward-values-item").removeClass("reward-values-item-selected");
    $(this).addClass("reward-values-item-selected");
});

//去赞赏
$(".reward-submit").click(function(){
    var reward_money = $(".reward-values-item-selected i").text();
    var pay_type = $("input[name='pay_type']:checked").val();
    //去赞赏
    nc.api("Article.Reward.reward",{ 'article_id' : '{$article_id}', 'access_token': "{$access_token}", "money" : reward_money},function (res) {
        if(res.code == 0){
            location.href = nc.url("Article://wap/reward/doReward", {"out_trade_no" : res.data,"pay_type" : pay_type});
        }else{
            if(res.code == 500){
                location.href = nc.url("wap/login/login");
            }
        }
    }, false);
})
</script>
{/block}